<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="大地坐标X" prop="gpsX" label-width="120px">
        <el-input
          v-model="queryParams.gpsX"
          placeholder="请输入大地坐标X"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="大地坐标Y" prop="gpsY" label-width="120px">
        <el-input
          v-model="queryParams.gpsY"
          placeholder="请输入大地坐标Y"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="搜索半径" prop="radius">
        <el-input
          v-model="queryParams.radius"
          placeholder="请输入搜索半径"
          clearable
          @keyup.enter="handleQuery">
          <template #append>KM</template>
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="wellBaseList">
      <el-table-column type="index" width="100" label="序号" align="center">
        <template slot-scope="scope">

        </template>
      </el-table-column>
      <el-table-column label="井号" align="center" prop="wellNo"/>
      <el-table-column label="作业队伍" align="center" prop="wellNo"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="220">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
                     v-hasPermi="['helper:wellBase:edit']">修改
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup name="WellBase">
import {listWellBase, getWellBase, delWellBase, addWellBase, updateWellBase} from "@/api/loss/wellBase";

const router = useRouter();
const {proxy} = getCurrentInstance();
const {default_status} = proxy.useDict('default_status');

const wellBaseList = ref([]);
const open = ref(false);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    gpsX: '',
    gpsY: '',
    radius: '',
    status: undefined,
    createDept: undefined,
  }
});

const {queryParams, form, rules} = toRefs(data);
loadData();

function loadData() {
  loading.value = false;
}

/** 查询钻井信息列表 */
function getList() {
  loading.value = true;
  listWellBase(queryParams.value).then(response => {
    wellBaseList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    wellNo: null,
    gpsX: null,
    gpxY: null,
    altitude: null,
    status: null,
    createBy: null,
    createDept: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
    remark: null,
    delFlag: null
  };
  proxy.resetForm("wellBaseRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}
</script>
